/*
 * Location.cpp
 *
 *  Created on: 15-Dec-2009
 *      Author: pmui
 */

#include <QDebug>
#include "location.h"

Location::Location()
{
#ifdef Q_OS_SYMBIAN
	// Only in Symbian, dummy results for others
	m_posInfoSource = QGeoPositionInfoSource::createDefaultSource(this);
	
	if(m_posInfoSource)
	{
		connect(m_posInfoSource, SIGNAL(positionUpdated(const QGeoPositionInfo &)), this,
				SLOT(positionUpdated(const QGeoPositionInfo&)));
		
		m_posInfoSource->startUpdates();
	}
#endif
}

Location::~Location()
{
}

void Location::setEnvironment(QMainWindow *parentWindow, QWebFrame *webFrame)
{
	
}

#ifdef Q_OS_SYMBIAN
void Location::positionUpdated(const QGeoPositionInfo& positionInfo)
{
	m_currentPosition = positionInfo;
	emit positionUpdated();
}
#endif

double Location::longitude()
{
	qDebug() << "[log] longitude called";
#ifdef Q_OS_SYMBIAN
	return m_currentPosition.coordinate().longitude();
#else
	return 2.150704;
#endif
}

double Location::latitude()
{
	qDebug() << "[log] latitude called";
#ifdef Q_OS_SYMBIAN
	return m_currentPosition.coordinate().latitude();
#else
	return 41.372718;
#endif
}

double Location::altitude()
{
#ifdef Q_OS_SYMBIAN
	return m_currentPosition.coordinate().altitude();
#else
	return 0;
#endif
}

int Location::satelliteNumView()
{
	return 0;
}

int Location::satelliteNumViewUsed()
{
	return 0;
}

int Location::horizontalSpeed()
{	
	return 0;
}

int Location::horizontalSpeedError()
{
	return 0;
}

int Location::trueCourse()
{
	return 0;
}

int Location::trueCourseError()
{
	return 0;
}

int Location::magneticHeading()
{
	return 0;
}

int Location::magneticHeadingError()
{
	return 0;
}

int Location::heading()
{
	return 0;
}

int Location::headingError()
{
	return 0;
}

int Location::magneticCourse()
{
	return 0;
}

int Location::magneticCourseError()
{
	return 0;
}

